$(document).ready(function(){
	var chosenCoursesNum = 0;
	var toSaveSelection = false;
	
	var courseRow = '<tr class="course-cell-hover"><td><a class="btn btn-small btn-primary" href="#"><i class="icon-info-sign icon-white"></i></a></td><td>סטטיסטיקה</td></tr>';            

	
	/* The user clicked on a course and chose it */
	/*$('#courseTable').delegate('tr', 'click', function() {
		var courseName = $(this).text();
		
		// Gets course' element current class
		var tdClassName = $(this).attr("class");
		if(tdClassName == 'course-cell-hover'){
			// Updates current class of course' cell: chosen or nor chosen
			$(this).removeClass('course-cell-hover');
			$(this).addClass('course-cell-highlight');
			
			$('<tr class="cl-' + courseName +'"><td>' + courseName + '</tr></td>').appendTo('.chosenCourses');
			
			// Adds the chosen course to the chosen courses list
			//items.push(courseName);
			chosenCoursesNum++;
			isChosen = true;
		}
		else{
			// Updates current class of course' cell: chosen or nor chosen
			$(this).removeClass('course-cell-highlight');
			$(this).addClass('course-cell-hover');
			$('.cl-' + courseName).remove();
			
			// Removes the chosen course from the chosen courses list
			chosenCoursesNum--;
			isChosen = false;
			
		}

	});*/
	
	$('ul#departmentList li').click(function() {
		$(this).addClass('depart-cell-highlight');
		
		var liClassName = $(this).attr('id');
		var request = $.ajax({
			 	type: "GET",
			    url: "/courses",
			    data: { depNum: liClassName },
                success: function(data)
                {
                	alert(data);
                }
        });//ajax closed
	});
	
	
	$('#addCourses').click(function(){
		toSaveSelection = true;
	});
	
	$('#courseCatalogExit1').click(function(){
		toSaveSelection = false;
	});
	
	$('#courseCatalogExit2').click(function(){
		toSaveSelection = false;
	});
	
	/* Disables the scrolling of the course catalog modal */ 
	$('#courseCatalogModal').css('max-height', 'none');
	



});

